﻿<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:local="clr-namespace:EIA.SLClient.PlatManage.BasicMgr"
	xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:utils="clr-namespace:EIA.SLClient.Utility;assembly=EIA.SLClient.Utility"
	xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
	mc:Ignorable="d"
	x:Class="EIA.SLClient.PlatManage.BasicMgr.PositionListView"
	d:DesignWidth="640" d:DesignHeight="480">
    <UserControl.Resources>
        <local:PositionListViewModel x:Key="PositionListViewModelDataSource" />
        <DataTemplate x:Key="OptDataTemplate">
        	<StackPanel d:DesignWidth="100" Orientation="Horizontal">
                <HyperlinkButton Content="编辑" CommandParameter="{Binding}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="8,0" BorderThickness="0">
                    <utils:BindingHelper.AncestorBinding>
                        <utils:AncestorBinding TargetPath="Command" AncestorPath="DataContext.UpdateItemCommand" AncestorTypeName="DataGrid"/>
                    </utils:BindingHelper.AncestorBinding>
                </HyperlinkButton>
                <HyperlinkButton Content="删除" CommandParameter="{Binding}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="8,0">
                    <utils:BindingHelper.AncestorBinding>
                        <utils:AncestorBinding TargetPath="Command" AncestorPath="DataContext.DeleteItemCommand" AncestorTypeName="DataGrid"/>
                    </utils:BindingHelper.AncestorBinding>
                </HyperlinkButton>
            </StackPanel>
        </DataTemplate>
    </UserControl.Resources>
	<UserControl.FontSize>
		<StaticResource ResourceKey="FontSize"/>
	</UserControl.FontSize>
	<UserControl.FontFamily>
		<StaticResource ResourceKey="FontFamily"/>
	</UserControl.FontFamily>

    <Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource PositionListViewModelDataSource}}">
    	<i:Interaction.Triggers>
    		<i:EventTrigger>
    			<ei:CallMethodAction TargetObject="{Binding Mode=OneWay}" MethodName="OnLoad"/>
    		</i:EventTrigger>
    	</i:Interaction.Triggers>
        <Grid Margin="4" Background="#FFF2F2F2">
            <Grid.Effect>
                <DropShadowEffect BlurRadius="1" ShadowDepth="1" Opacity="0.1"/>
            </Grid.Effect>
            <Grid.RowDefinitions>
                <RowDefinition Height="32"/>
                <RowDefinition/>
                <RowDefinition Height="32"/>
            </Grid.RowDefinitions>
            <Border BorderBrush="#FFE1E1E1" BorderThickness="1">
                <Border.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FFFCFCFC" Offset="0"/>
                        <GradientStop Color="#FFEBEBEB" Offset="1"/>
                    </LinearGradientBrush>
                </Border.Background>
                <Grid>
                	<HyperlinkButton Content="添加" Command="{Binding InsertItemCommand}" HorizontalAlignment="Left" Margin="8,0,0,0" VerticalAlignment="Center" />
                	<HyperlinkButton Content="重新载入" Command="{Binding RetrieveItemsCommand}" HorizontalAlignment="Right" Margin="0,0,8,0" VerticalAlignment="Center" />
                </Grid>
            </Border>
            <Border BorderBrush="#FFE1E1E1" BorderThickness="1,0" Grid.Row="1">
                <Grid>
                    <sdk:DataGrid ItemsSource="{Binding TPositionCollection}">
                        <sdk:DataGrid.Columns>
                            <sdk:DataGridTextColumn Header="职位" MinWidth="160" Binding="{Binding PosName}" CanUserSort="True" />
                            <sdk:DataGridTextColumn Header="级别" MinWidth="60" Binding="{Binding PosLevel}" CanUserSort="True"/>
							<sdk:DataGridTemplateColumn Header="操作" CellTemplate="{StaticResource OptDataTemplate}"/>
                        </sdk:DataGrid.Columns>
                    </sdk:DataGrid>
                </Grid>
            </Border>
            <Border BorderBrush="#FFE1E1E1" BorderThickness="1" Grid.Row="2" Background="WhiteSmoke">
                <Grid/>
            </Border>
        </Grid>
    </Grid>
</UserControl>
